<style lang="scss">
	page{
		background: #FFFFFF;
		// padding-top: 30upx;
		height: auto;
		.all{
			width: 750upx;
			.placeholder_input{
				width: 520upx;
				height: 60upx;
				border: 1upx solid #D8D8D8;
				line-height: 60upx;
				margin-bottom: 20upx;
				font-size: 22upx;
			}
			.list{
				width: 690upx;
				padding: 30upx;
				border-bottom: 1upx solid #DDDDDD;
				display: flex;
				.list_image{
					width: 80upx;
					height: 80upx;
					border-radius: 50%;
				}
				.list_text{
					margin-left: 24upx;
					margin-top: 0;
					.list_text_name{
						width: 420upx;
						display: flex;
						.list_text_name_text_new{
							max-width: 220upx;
							height: 42upx;
							font-size: 30upx;
							font-weight: bold;
							color: #333333;
							line-height: 42upx;
							overflow:hidden;
							text-overflow:ellipsis;
							white-space:nowrap;
							display: inline-block;
						}
						.list_text_name_text{
							display: inline-block;
							width: 200upx;
							height: 36upx;
							line-height: 42upx;
							font-size: 26upx;
							font-weight: 400;
							margin-left: 10upx;
							overflow:hidden;
							text-overflow:ellipsis;
							white-space:nowrap;
						}
					}
					.list_text_sl{
						width: 420upx;
						height: 34upx;
						font-size: 24upx;
						font-weight: 400;
						color: #A02731;
						line-height: 34upx;
						margin-top: 8upx;
					}
				}
				.list_anniu{
					width: 148upx;
					height: 60upx;
					background: #A02731;
					border: 2upx solid #A02731;
					text-align: center;
					line-height: 60upx;
					font-size: 24upx;
					color: #FFFFFF;
					margin-top: 22upx;
				}
			}
			.zanwu{
				width: 100%;
				line-height: 100upx;
				height: 100upx;
				color: #999999;
				font-size: 28upx;
				text-align: center;
			}
		}
	}
</style>
<template>
	<view class="all">
		<view class="list" v-if="list_data.length != 0" v-for="(item,index) in list_data" :key="index">
			<image class="list_image" :src="item.avatar_url"></image>
			<view class="list_text">
				<view class="list_text_name"> <view class="list_text_name_text_new"> {{item.nickname}} </view> 
				</view>
				<view class="list_text_sl">{{item.phone}}</view>
			</view>
		</view>
		<view v-if="list_data.length == 0" class="zanwu">暂无更多数据</view>
	</view>
</template>
<script>
	import urlConfig from '../../common/config.js';
	export default {
		data() {
			return {
				list_data:[],
				page:1,
				promptVisible:false,
				user_id:'',
				password_data:'',
				money:''
			}
		},
		onLoad() {
			if( !uni.getStorageSync('access_token') ) {
				uni.showModal({
					title: '提示',
					content: '请先登录',
					cancelText:'返回',
					confirmColor:'#A02731',
					success: function (res) {
						if (res.confirm) {
							console.log('用户点击确定');
							uni.reLaunch({
								url:'../disembark/disembark'
							})
						} else if (res.cancel) {
							wx.closeWindow()
						}
					}
				});
			}
			this.friend_api()
		},
		methods: {
			password_tap(num) {
				console.log(num)
				this.password_data = num.detail.value
			},
			clickPromptConfirm(money) {
			  var that = this
			  that.money = money
			  if( that.password_data != '' ) {
				  uni.request({
				  	url: urlConfig.Url + 'api/friend/transfer',
				  	data:{
				  		access_token:uni.getStorageSync('access_token'),
				  		user_id:that.user_id,
				  		money:money,
						password:that.password_data
				  	},
				  	method: 'POST',
				  	header: {
				  		'content-type': 'application/x-www-form-urlencoded'
				  	},
				  	success: (res) => {
				  		if (res.data.code == 0) {
				  			that.promptVisible = false
				  		} else if (res.data.code == -1) {
				  			uni.reLaunch({
				  				url:'../disembark/disembark'
				  			})
				  		} else {
				  			uni.showToast({
				  				title: res.data.msg,
				  				duration: 2000,
				  				icon: 'none'
				  			});
				  		}
				  	}
				  });
			  }else{
				  uni.showToast({
				  	title: '请输入交易密码',
				  	duration: 2000,
				  	icon: 'none'
				  });
			  }
			},
			transfer(user_id) {
				var that = this
				that.promptVisible = true
				that.user_id = user_id
			},
			//获取首页
			friend_api() {
				var that = this
				that.$request(that.$Api.friends_team_api, {
					access_token: uni.getStorageSync('access_token'),
					page:that.page
				}, "POST").then(res => {
					if (res.data.code == 0) {
						that.list_data = res.data.data.list
					} else {
						uni.showToast({
							title: res.data.msg,
							duration: 2000,
							icon: 'none'
						});
					}
				})
			},
			check_tap(user_id) {
				var that = this
				uni.showModal({
				    title: '提示',
				    content: '是否确认通过',
				    success: function (res) {
				        if (res.confirm) {
				            uni.request({
				            	url: urlConfig.Url + 'api/friend/check',
				            	data:{
				            		access_token:uni.getStorageSync('access_token'),
				            		user_id:user_id
				            	},
				            	method: 'POST',
				            	header: {
				            		'content-type': 'application/x-www-form-urlencoded'
				            	},
				            	success: (res) => {
				            		if (res.data.code == 0) {
				            			that.page = 1
				            			that.friend_api()
				            		} else if (res.data.code == -1) {	
				            		} else {
				            			uni.showToast({
				            				title: res.data.msg,
				            				duration: 2000,
				            				icon: 'none'
				            			});
				            		}
				            	}
				            });
				        } else if (res.cancel) {
				            console.log('用户点击取消');
				        }
				    }
				});
			},
		},
		onReachBottom() {
			var that = this
			that.page++
			that.$request(that.$Api.friends_team_api, {
				access_token: uni.getStorageSync('access_token'),
				page:that.page
			}, "POST").then(res => {
				if (res.data.code == 0) {
					if( res.data.data.list.length != 0 ) {
						that.list_data = that.list_data.concat(res.data.data.list)
					}else{
						uni.showToast({
							title: '暂无更多数据',
							duration: 2000,
							icon: 'none'
						});
					}
				} else {
					uni.showToast({
						title: res.data.msg,
						duration: 2000,
						icon: 'none'
					});
				}
			})
		}
	}
</script>



















